﻿namespace ZGDisassembler.Core;

/// <summary>
/// 寻址模式
/// </summary>
public class AddressingMode
{
	public byte MaxLength { get; set; } = 0;
	public Dictionary<string, AddressingModeProperty> SubProperty { get; set; } = new();
}

/// <summary>
/// 寻址模式属性
/// </summary>
public class AddressingModeProperty
{
	public string Instruction { get; internal set; }
	public string? AddressingMode { get; internal set; }
	public byte[]? AddressLength { get; internal set; }
	public byte[]? Multi { get; internal set; }
	public Func<AddressingModeProperty, uint, uint, uint?, ResultLine>? SpProcess { get; internal set; }

	#region 所有地址长度总和
	internal byte AllAddressLength()
	{
		if (AddressLength == null || AddressLength.Length == 0)
			return 0;

		byte sum = 0;
		for (var i = 0; i < AddressLength.Length; ++i)
			sum += AddressLength[i];

		return sum;
	}
	#endregion 所有地址长度总和

}
